package 抽象类的匿名子类对象;


import javafx.concurrent.Worker;

public class AbstractTest {

    public static void method(Person person){
        person.eat();
        person.talk();
    }

    public static void main(String[] args) {

        Student student = new Student();
        method(student); //非匿名的类非匿名的对象

        method(new Student()); //非匿名的类匿名的对象

        Person person = new Person() {  //创建一个匿名子类对象person
            @Override
            public void eat() {
                System.out.println("...");
            }

            @Override
            public void talk() {
                System.out.println("...");
            }
        };
        method(person);

        //创建匿名子类的匿名对象
        method(new Person() {
            @Override
            public void eat() {
                System.out.println("^^^^^");
            }

            @Override
            public void talk() {
                System.out.println("^^^^^");
            }
        });
    }

}

//抽象类
abstract class Person{

    public abstract void eat();

    public abstract void talk();

}

//子类
class Student extends Person{

    @Override
    public void eat() {

    }

    @Override
    public void talk() {

    }
}
